<template>
  <div class="contact-container">
    <el-card class="box-card">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="地址">
          <el-input v-model="form.addr" />
        </el-form-item>
        <el-form-item label="手机">
          <el-input v-model="form.cellPhone" />
        </el-form-item>
        <el-form-item label="电话">
          <el-input v-model="form.phone" />
        </el-form-item>
        <el-form-item label="邮编">
          <el-input v-model="form.postcode" />
        </el-form-item>
        <el-form-item label="传真">
          <el-input v-model="form.fax" />
        </el-form-item>
        <el-form-item label="邮箱">
          <el-input v-model="form.mailbox" />
        </el-form-item>
        <el-form-item label="微信">
          <el-input v-model="form.wechat" />
        </el-form-item>
        <el-form-item label="微博">
          <el-input v-model="form.weibo" />
        </el-form-item>
        <el-form-item label="地址图片">
          <el-input v-model="form.img" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click.native.prevent="ChangeSetting">确认</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import {
  getContact,
  modifyContact
} from '@/api/Contact'
export default {
  data() {
    return {
      form: {
        addr: '',
        cellPhone: '',
        phone: '',
        postcode: '',
        fax: '',
        mailbox: '',
        wechat: '',
        weibo: '',
        img: ''
      }
    }
  },
  created() {
    this.loadContact()
  },
  methods: {
    name: 'Contact',
    loadContact() {
      getContact().then(res => {
        this.form.addr = res.data.addr
        this.form.cellPhone = res.data.cellPhone
        this.form.phone = res.data.phone
        this.form.postcode = res.data.postcode
        this.form.fax = res.data.fax
        this.form.mailbox = res.data.mailbox
        this.form.wechat = res.data.wechat
        this.form.weibo = res.data.weibo
        this.form.img = res.data.img
      })
    },
    ChangeSetting() {
      modifyContact(this.form).then(data => {
        console.log(this.form)
        console.log(data.message)
        // alert(data.msg)
        this.$message({
          type: 'success',
          message: '成功'
        })
      })
    }

  }
}
</script>

<style>
.box-card {
  width: 100%;
}
</style>
